import java.sql.SQLOutput;
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s=in.next();
        int len=in.nextInt();
        int n=s.length();
        int max=0;
        int left=0,right=len-1;
        int dest=0,cur=0;
        while(right<n){
            int count=0;
            for(int i=left;i<=right;i++){
                if(s.charAt(i)=='G'||s.charAt(i)=='C'){
                    count++;
                }
            }
            if(max<count){
                dest=left;
                cur=right;
                max=count;
            }
            left++;
            right++;
        }
        for(int i=dest;i<=cur;i++){
            System.out.print(s.charAt(i));
        }
    }
    public static void main2(String[] args) {
        Scanner in=new Scanner(System.in);
        String str=in.next();
        char[] ch=new char[3];
        ch[0]='B';
        ch[1]='D';
        ch[2]='F';
        System.out.println(formatString(str,ch));
    }
    public static String formatString (String str, char[] arg) {
        StringBuilder s=new StringBuilder(str);
        s.append("?");
        int n=str.length();
        int j=0;
        for(int i=1;i<n;i++){
            if(s.charAt(i-1)=='%'&&s.charAt(i)=='s'){
                s.replace(i-1,i+1,String.valueOf(arg[j]));
                j++;
            }
        }
        s.deleteCharAt(s.length()-1);
        System.out.println(s.toString());
        while(j!=arg.length){
            s.append(arg[j]);
            j++;
        }

        return s.toString();
    }
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int a=in.nextInt();
        int b=in.nextInt();
        int count=0;
        for(int i=a;i<=b;i++){
            if(func(i)){
                count++;
            }
        }
        System.out.println(count);
    }
    public static boolean func(int num){
        String str=String.valueOf(num);
        char[] ch=str.toCharArray();
        for(int i=0;i<ch.length-1;i++){
            for(int j=i+1;j<ch.length;j++){
                int a=ch[i]-'0';
                int b=ch[j]-'0';
                if(func1(a*10+b)&&a!=0){
                    return true;
                }
                if(func1(b*10+a)&&b!=0){
                    return true;
                }
            }
        }
        return false;
    }
    public static boolean func1(int n){
        for(int i=2;i<=Math.sqrt(n);i++){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}